home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / tnos / tnos100s / udpcmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-30  |  1.2 KB  |  67 lines

  1. /* UDP-related user commands
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  */
  4. #include <stdio.h>
  5. #include <dos.h>
  6. #include "global.h"
  7. #include "mbuf.h"
  8. #include "netuser.h"
  9. #include "udp.h"
  10. #include "internet.h"
  11. #include "cmdparse.h"
  12. #include "commands.h"
  13.  
  14. static int doudpstat __ARGS((int argc,char *argv[],void *p));
  15.  
  16. static struct cmds Udpcmds[] = {
  17.     "status",    doudpstat,    0, 0,    NULLCHAR,
  18.     NULLCHAR,
  19. };
  20. int
  21. doudp(argc,argv,p)
  22. int argc;
  23. char *argv[];
  24. void *p;
  25. {
  26.     return subcmd(Udpcmds,argc,argv,p);
  27. }
  28. int
  29. st_udp(udp,n)
  30. struct udp_cb *udp;
  31. int n;
  32. {
  33.     if(n == 0)
  34.         tprintf("&UCB Rcv-Q  Local socket\n");
  35.  
  36.     return tprintf("%4.4x%6u  %s\n",FP_SEG(udp),udp->rcvcnt,pinet(&udp->socket));
  37. }
  38.  
  39. /* Dump UDP statistics and control blocks */
  40. static int
  41. doudpstat(argc,argv,p)
  42. int argc;
  43. char *argv[];
  44. void *p;
  45. {
  46.     register struct udp_cb *udp;
  47.     register int i;
  48.  
  49.     for(i=1;i<=NUMUDPMIB;i++){
  50.         tprintf("(%2u)%-20s%10lu",i,
  51.          Udp_mib[i].name,Udp_mib[i].value.integer);
  52.         if(i % 2)
  53.             tprintf("     ");
  54.         else
  55.             tprintf("\n");
  56.     }
  57.     if((i % 2) == 0)
  58.         tprintf("\n");
  59.  
  60.     tprintf("&UCB Rcv-Q  Local socket\n");
  61.     for(udp = Udps;udp != NULLUDP; udp = udp->next){
  62.         if(st_udp(udp,1) == EOF)
  63.             return 0;
  64.     }
  65.     return 0;
  66. }
  67.